function [Q] = gmm_se(x,pi_bar,pi_lim,f_data,g5_data,g10_data,bt,mdl)

A = Amatrix(x,mdl);                                                         % constructing the A matrix

f = (A(bt,:)*(A^(5) + A^(6) + A^(7) + A^(8) + A^(9)))'/5;                   % marginal distribution of inflation at t+6~t+10 in the model

[g5,g10] = avg_inf_510(A,bt,pi_bar,pi_lim);                                 % distribution of 5y and 10y average inflations in the model

q = [(f - f_data); (g5 - g5_data); (g10 - g10_data)];

Q = (q'*q/24)^(1/2);                                                        % objective function: root MSE
Q = (q'*q/24);                                                        % objective function:  MSE

fg_d = [f_data; g5_data; g10_data];
SST = sum((fg_d - mean(fg_d)).^2);
r2 = [1 - q'*q/SST q'*q SST];
end
